package com.nifostasky.pattern.consumer;

import com.nifostasky.pattern.config.RabbitDirectConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 路由模式消费者
 *  直连交换机消息消费者
 */
@Slf4j
@Component
public class DirectConsumer {

    /**
     * 这个方法同时监听两个管道
     * @param message
     */
    @RabbitListener(queues = {RabbitDirectConfig.QUEUE_NAME_INSERT, RabbitDirectConfig.QUEUE_NAME_UPDATE})
    public void directQueue(Message message){
        log.info(message.toString());
        log.info(new String(message.getBody()));
    }
}
